package com.hbnu.test.www.net;

import java.io.*;
import java.net.Socket;

public class TCP_client05 {
    public static void main(String[] args) {
        try (Socket socket = new Socket("127.0.0.1", 8888);FileInputStream fileInputStream = new FileInputStream(new File("C:\\Users\\92077\\Pictures\\Saved Pictures\\0001.jpeg"));){


            OutputStream out = socket.getOutputStream();
            BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream()));
            int len = 0;
            byte[] bytes = new byte[1024];
            while((len = fileInputStream.read(bytes))!=-1){
                out.write(bytes,0,len);
            }
            socket.shutdownOutput();
            String result = in.readLine();
            System.out.println("图片上传结果为：" + result);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
